package com.zgr.ssh.action;

import com.zgr.ssh.dao.IPlantDao;
import com.zgr.ssh.entity.Plant;
import org.hibernate.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class PlantAction extends SuperAction {

    @Autowired
    public IPlantDao plantDaoImpl;

    private Plant plant = new Plant();

    public Plant getPlant() {
        return plant;
    }

    public String showPlant(){
        List<Plant> list = plantDaoImpl.getPlantIsUp();
        session.setAttribute("list",list);

        return "show_plant";
    }

    /**
     * 上线
     * @return
     */
    public String upLine(){
        Integer id = Integer.valueOf(request.getParameter("id"));
        plantDaoImpl.upLine(id);
        return "up_success";
    }

    /**
     * 下线
     * @return
     */
    public String downLine(){
        Integer id = Integer.valueOf(request.getParameter("id"));
        plantDaoImpl.downLine(id);
        return "down_success";
    }

}
